<%@ page import="rcfirewall.SubnetUtils"%>
<%@ page import="rcfirewall.conexaoBD"%>
<%@ page import="rcfirewall.verificaIP"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Softpar Firewall</title>
</head>
<body>
<%
String net = request.getParameter("net");

String mask = request.getParameter("mask");

String name = request.getParameter("name");

verificaIP ip = new verificaIP();
conexaoBD bd = new conexaoBD();


if (ip.validaIP(net) == true){
	
	SubnetUtils sub = new SubnetUtils(net,mask);
	String result = sub.toCidrNotation(net, mask);
	bd.insertBD("insert into DESTINATION (name,ip_address) value (\'" + name + "\',\'" + result + "\')" );

out.println("A rede: " + sub.toCidrNotation(net, mask) + " foi adicionada com sucesso");
}else{
	
	out.println("Endereço de Rede Inválido");
}

%>

</body>
</html>